package Acwing.基础算法;

import java.util.Scanner;

/**
 * @Title: binary1
 * @Author 贾金博
 * @Package Acwing.基础算法
 * @Date 2025/4/8 下午10:39
 * @description: 二分基础
 */
public class binary1 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();

        int[] a = new int[n + 10];
        for(int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
        }

        while(q -- > 0 ) {
            int x = sc.nextInt();

            // 找到x的第一个位置
            int pos1 = findFirst(x, a, n);

            if(pos1 == -1) {
                System.out.println(-1 + " " + -1);
            } else {

                // 找到x的最后一个位置
                int pos2 = findLast(x, a, n);
                pos1 --;
                pos2 --;
                // 他们的下标是从0开始的
                System.out.println(pos1 + " " + pos2);
            }

        }

    }

    public static int findFirst(int x, int[] a, int n) {
        int pos = -1;
        int l = 0, r = n + 1;
        while(l + 1 < r) {
            int mid = (l + r) / 2;
            if(a[mid] < x) {
                l = mid;
            } else {
                r = mid;
            }
        }
        if(a[r] == x) { // 第一个大于等于x的位置
            pos = r;
        }

        return pos;
    }

    public static int findLast(int x, int[] a, int n) {
        int pos = -1;
        int l = 0, r = n + 1;
        while(l + 1 < r) {
            int mid = (l + r) / 2;
            if(a[mid] <= x) {
                l = mid;
            } else {
                r = mid;
            }
        }
        // 找到最后一个小于等于x的
        if(a[l] == x) {
            pos = l;
        }
        return pos;
    }


}
